package com.cykj.pos.controller.api;

import com.cykj.pos.domain.ReceiverParam;
import com.cykj.pos.util.XinlongSignUtil;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.Date;

/**
 * 薪龙E签宝回调测试类
 */
@RequiredArgsConstructor(onConstructor_ = @Autowired)
@RestController
@RequestMapping("/pose")
public class YbCont {
    @ApiOperation("签约回调")
    @PostMapping("/receiver/callBack")
    @Transactional
    public String success(HttpServletRequest request, @RequestParam String requestBody) throws Exception {
        System.out.println("---------回调时间：" + new Date() + "-------------------------------------");
        System.out.println("--------------------------------------------------------------------");
        System.out.println("---------签约回调结果" + requestBody + "----------------------------------------");
        System.out.println("--------------------------------------------------------------------");
        System.out.println("--------------------------------------------------------------------");
        System.out.println("--------------------------------------------------------------------");
        System.out.println("--------------------------------------------------------------------");
        XinlongSignUtil xl=new XinlongSignUtil("402764463259168768",
                "QXAaaMETWCpaC3cP",
                "V1.1.0","402764636353904641",
                "402764605378965504",
                "323331000007777","www.baidu.com",
                "http://mxm.vaiwan.com/pose/receiver/callBack",
                "http://mxm.vaiwan.com/pose/receiver-tx/callBack");
        xl.deRequestBody(requestBody);//jsonobject
        return "SUCCESS";
    }

    @ApiOperation("提现回调")
    @PostMapping("/receiver-tx/callBack")
    @Transactional
    public String txSuccess(HttpServletRequest request, @RequestParam String requestBody) throws Exception {
        System.out.println("---------回调时间：" + new Date() + "-------------------------------------");
        System.out.println("--------------------------------------------------------------------");
        System.out.println("---------提现回调结果" + requestBody + "----------------------------------------");
        System.out.println("--------------------------------------------------------------------");
        System.out.println("--------------------------------------------------------------------");
        System.out.println("--------------------------------------------------------------------");
        XinlongSignUtil xl=new XinlongSignUtil("402764463259168768",
                "QXAaaMETWCpaC3cP",
                "V1.1.0","402764636353904641",
                "402764605378965504",
                "323331000007777","www.baidu.com",
                "http://mxm.vaiwan.com/pose/receiver/callBack",
                "http://mxm.vaiwan.com/pose/receiver-tx/callBack");
        xl.deRequestBody(requestBody);
        return "SUCCESS";
    }

}
